package com.example.langchain4j.tools;

import com.example.langchain4j.pojo.Reservation;
import com.example.langchain4j.service.ReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
@Component
public class ReservationTool {
    @Autowired
    private ReservationService reservationService;
    @Tool("添加志愿指导服务预约")
    public void addReservation(
            @P("考生姓名") String name,
            @P("考生性别") String gender,
            @P("考生手机号") String phone,
            @P("考生沟通时间,格式为: yyyy-MM-dd'T'HH:mm") String communicationTime,
            @P("考生所在省") String province,
            @P("考生预计分数") Integer estimatedScore

    )
    {
        Reservation reservation = new Reservation(null, name,gender,phone,LocalDateTime.parse(communicationTime),province,estimatedScore);
        reservationService.insert(reservation);
    }
    @Tool("通过手机号查询考生预约详情")
    public Reservation selectForPhone(
            @P("考生手机号") String phone
    )
    {
        return reservationService.selectForPhone(phone);
    }

}
